#include<iostream>
using namespace std;
int main(){
    int days[11]={31,0,31,30,31,30,31,31,30,31,30};
    int year,month,date;
    
    while(cin>>year){
    int sum=0;
    cin.ignore();
    cin>>month;
    cin.ignore();
    cin>>date;
    if(year%400==0||(year%4==0&&year%100!=0)){
        days[1]=29;
    }else{
        days[1]=28;
    }
    while (month>1)
    {
        sum=sum+days[month-2];
        month--;
    }
    sum+=date;
    cout<<sum<<endl;
    }
}